﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NewsVariableTile.Data;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace NewsVariableTile.VariableTemplate
{
    public class VariableTiles : DataTemplateSelector
    {

        public DataTemplate LatestNewsBigTemplate { get; set; }
        public DataTemplate LatestNewsSmallTemplate { get; set; }
        public DataTemplate NationalBigTemplate { get; set; }
        public DataTemplate NationalSmallTemplate { get; set; }
        public DataTemplate NationalMediumTemplate { get; set; }
        public DataTemplate NationalLTemplate { get; set; }
        public DataTemplate FavouritesBigTemplate { get; set; }
        public DataTemplate FavouritesSmallTemplate { get; set; }
        public DataTemplate FavouritesLTemplate { get; set; }
        
    
      

        protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)
        {
            FrameworkElement element = container as FrameworkElement;

            if (element!=null && item != null)
            {

                if ((item as SampleDataItem).UniqueId.StartsWith("LatestNewsBig"))
                    return LatestNewsBigTemplate;
                if ((item as SampleDataItem).UniqueId.StartsWith("LatestNewsSmall"))
                    return LatestNewsSmallTemplate;
                if ((item as SampleDataItem).UniqueId.StartsWith("NationalBig"))
                    return NationalBigTemplate;
                if ((item as SampleDataItem).UniqueId.StartsWith("NationalSmall"))
                    return NationalSmallTemplate;
                if ((item as SampleDataItem).UniqueId.StartsWith("NationalMedium"))
                    return NationalMediumTemplate;
                if ((item as SampleDataItem).UniqueId.StartsWith("NationalL"))
                    return NationalLTemplate;
                if ((item as SampleDataItem).UniqueId.StartsWith("FavouritesBig"))
                    return FavouritesBigTemplate;
                if ((item as SampleDataItem).UniqueId.StartsWith("FavouritesSmall"))
                    return FavouritesSmallTemplate;
                if ((item as SampleDataItem).UniqueId.StartsWith("FavouritesL"))
                    return FavouritesLTemplate;
               
                
            }
            return base.SelectTemplateCore(item, container);
        }

    }
}
